package com.api.hrm.util;

import com.api.browser.bean.BrowserBean;
import com.api.browser.bean.BrowserValueInfo;
import com.api.browser.service.BrowserValueInfoService;
import com.api.browser.util.BrowserInitUtil;
import com.api.browser.util.ConditionFactory;
import com.api.hrm.bean.HrmFieldBean;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionType;

import com.engine.cube.biz.CardFormHelper;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.sensitive.biz.SensitiveWordComInfo;
import com.engine.sensitive.biz.SensitiveWordTypeComInfo;
import weaver.cache.CacheBase;
import weaver.cache.CacheColumn;
import weaver.cache.CacheColumnType;
import weaver.cache.PKColumn;
import weaver.conn.RecordSet;
import weaver.docs.docs.CustomFieldManager;
import weaver.file.ImageFileManager;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.definedfield.HrmFieldManager;
import weaver.systeminfo.SystemEnv;

import java.util.*;

/**
 * 人力资源查询条件
 * @author lvyi
 *
 */
public class HrmFieldSearchConditionComInfo extends CacheBase
{
	//需要定义的信息 begin
	protected static String TABLE_NAME = "hrm_searchfield";
	/** sql中的where信息，不要以where开始 */
	protected static String TABLE_WHERE = null;
	/** sql中的order by信息，不要以order by开始 */
	protected static String TABLE_ORDER = "pageid, itemorder, fieldorder";

	@PKColumn(type = CacheColumnType.NUMBER)
	protected static String PK_NAME = "fieldid";
	
	@CacheColumn(name = "fieldname")
  protected static int fieldname;
	@CacheColumn(name = "fieldhtmltype")
  protected static int fieldhtmltype;
	@CacheColumn(name = "type")
  protected static int type;
	@CacheColumn(name = "fieldlabel")
  protected static int fieldlabel;
	@CacheColumn(name = "fieldorder")
  protected static int fieldorder;
	@CacheColumn(name = "isuse")
  protected static int isuse;
	@CacheColumn(name = "isQuickSearch")
  protected static int isQuickSearch;
	@CacheColumn(name = "isscope")
  protected static int isscope;
	@CacheColumn(name = "itemtitle")
  protected static int itemtitle;
	@CacheColumn(name = "itemorder")
  protected static int itemorder;
	@CacheColumn(name = "pageid")
  protected static int pageid;

  public String getId(){
    return (String)(getRowValue(PK_INDEX));
  }
  
	public String getFieldname(){
	  return (String)(getRowValue(fieldname));
	}
	
	public String getFieldname(String key){
	   return (String)getValue(fieldname, key);
	}
	
	public String getFieldhtmltype(){
	  return (String)(getRowValue(fieldhtmltype));
	}
	
	public String getFieldhtmltype(String key){
	   return (String)getValue(fieldhtmltype, key);
	}
	
	public String getType(){
	  return (String)(getRowValue(type));
	}
	
	public String getType(String key){
	   return (String)getValue(type, key);
	}
	
	public String getFieldlabel(){
	  return (String)(getRowValue(fieldlabel));
	}
	
	public String getFieldlabel(String key){
	   return (String)getValue(fieldlabel, key);
	}
	
	public String getFieldorder(){
	  return (String)(getRowValue(fieldorder));
	}
	
	public String getFieldorder(String key){
	   return (String)getValue(fieldorder, key);
	}
		
	public String getIsuse(){
	  return (String)(getRowValue(isuse));
	}
	
	public String getIsuse(String key){
	   return (String)getValue(isuse, key);
	}
	
	public String getPageid(){
	  return (String)(getRowValue(pageid));
	}
	
	public String getPageid(String key){
	   return (String)getValue(pageid, key);
	}
	
	public String getItemtitle(){
	  return (String)(getRowValue(itemtitle));
	}
	
	public String getItemtitle(String key){
	  return (String)getValue(itemtitle, key);
	}
	
	public String getItemorder(){
	  return (String)(getRowValue(itemorder));
	}
	
	public String getItemorder(String key){
	  return (String)getValue(itemorder, key);
	}
	
	public String getIsQuickSearch(){
	  return (String)(getRowValue(isQuickSearch));
	}
	
	public String getIsQuickSearch(String key){
	  return (String)getValue(isQuickSearch, key);
	}
	
	public String getIsscope(){
	  return (String)(getRowValue(isscope));
	}
	
	public String getIsscope(String key){
	  return (String)getValue(isscope, key);
	}

	public static String DATE_SELECT = "select";
	public static String DATE_FROM = "from";
	public static String DATE_TO = "to";
  public static String DATE_Time_FROM = "_start";
  public static String DATE_Time_TO = "_end";
  private String isMobile = "";

	public LinkedHashMap<String, List<HrmFieldBean>> getSearchCondition(String pageid, User user){
		LinkedHashMap<String, List<HrmFieldBean>> searchCondition = new LinkedHashMap<String, List<HrmFieldBean>>();
		List<HrmFieldBean> lsFieldInfo = null;
		HrmFieldBean hrmFieldBean = null;
		this.setTofirstRow();
		String olditemtitle = ""; 
		while(this.next()){
			if(!pageid.equals(this.getPageid()))continue;
			if(!this.getIsuse().equals("1"))continue;
			String itemtitle = this.getItemtitle();
			lsFieldInfo = searchCondition.get(itemtitle);
			if(lsFieldInfo==null){
				lsFieldInfo = new ArrayList<HrmFieldBean>();
				searchCondition.put(itemtitle, lsFieldInfo);
			}
			
		 	if(pageid.equals("HRMRESOURCESEARCH")){//加载自定义字段
		  	if(olditemtitle.length()>0 && !olditemtitle.equals(itemtitle)){
		  		getDefinedSearchCondition(searchCondition.get(olditemtitle),olditemtitle);
		  	}
		  	olditemtitle = itemtitle;
	  	}
		 	
			hrmFieldBean = new HrmFieldBean();
			hrmFieldBean.setFieldid(this.getId());
			hrmFieldBean.setFieldname(this.getFieldname());
			hrmFieldBean.setFieldlabel(this.getFieldlabel());
	  	hrmFieldBean.setFieldhtmltype(this.getFieldhtmltype());
	  	hrmFieldBean.setType(this.getType());
	  	hrmFieldBean.setIsQuickSearch(this.getIsQuickSearch().equals("1"));
	  	hrmFieldBean.setIsScope(this.getIsscope().equals("1"));
	  	lsFieldInfo.add(hrmFieldBean);
		}
		return searchCondition;
	}
	
	public void getDefinedSearchCondition(List<HrmFieldBean> lsFieldInfo, String itemtitle){
		HrmFieldBean hrmFieldBean = null;
		if(itemtitle.equals("1361") || itemtitle.equals("15687")){}
		else{
			return;
		}

		int scopeId = -1;
		if(itemtitle.equals("15687")){
			scopeId =1;
		}
   	CustomFieldManager cfm = new CustomFieldManager("HrmCustomFieldByInfoType",scopeId);
		cfm.getCustomFields();
		if(scopeId==-1)scopeId = 0;
		
		while(cfm.next()){
			if(cfm.getHtmlType().equals("6")||!cfm.isUse())continue;
			hrmFieldBean = new HrmFieldBean();
			hrmFieldBean.setFieldid(""+cfm.getId());
			hrmFieldBean.setFieldname("column_"+scopeId+"_"+cfm.getId());
			hrmFieldBean.setFieldlabel(cfm.getLable());
	  	hrmFieldBean.setFieldhtmltype(cfm.getHtmlType());
	  	hrmFieldBean.setType(""+cfm.getType());
			hrmFieldBean.setDmlurl(""+cfm.getDmrUrl());
	  	lsFieldInfo.add(hrmFieldBean);
		}
	}
	
	public SearchConditionItem getSearchConditionItem(HrmFieldBean hrmFieldBean, User user){
		SearchConditionItem searchConditionItem = null;
		try{
			if(user==null){
				user = new User();
				user.setLanguage(7);
			}
			ConditionFactory conditionFactory = new ConditionFactory(user);
			HrmFieldManager hrmFieldManager = new HrmFieldManager();
			RecordSet rs = null;
			String fieldid = Util.null2String(hrmFieldBean.getFieldid());//字段id
			String fieldname = Util.null2String(hrmFieldBean.getFieldname());//字段名
			String fieldlabel = Util.null2String(hrmFieldBean.getFieldlabel());//字段显示名
	  	String fieldhtmltype = Util.null2String(hrmFieldBean.getFieldhtmltype());//字段类型
	  	String detailtype = Util.null2String(hrmFieldBean.getType());//字段二级类型（浏览框--单人力）
	  	Object fieldvalue = hrmFieldBean.getFieldvalue();
	  	String dmlurl = Util.null2String(hrmFieldBean.getDmlurl());
	  	boolean isQuickSearch = hrmFieldBean.getIsQuickSearch();
	  	boolean isScope = hrmFieldBean.getIsScope();
	  	int viewAttr = hrmFieldBean.getViewAttr();
	  	boolean multilang = hrmFieldBean.getMultilang();
	  	
	  	if(fieldhtmltype.equals("1")){//单行文本框
	  		if(isScope){//范围
	  			if(Util.null2String(fieldvalue).length()==0){
	  				fieldvalue = new HashMap<String, Object>(); 
	  			}
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.SCOPE, fieldlabel,new String[]{fieldname,fieldname+"to"});
	  		}else if(detailtype.equals("2")){//数字
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.INPUTNUMBER, fieldlabel, fieldname,isQuickSearch);
	  		}else{
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, fieldlabel, fieldname,isQuickSearch);
	  		}
	  	}else	if(fieldhtmltype.equals("2")){//多行文本框
	  		searchConditionItem = conditionFactory.createCondition(ConditionType.TEXTAREA, fieldlabel, fieldname);
	  	}else	if(fieldhtmltype.equals("3")){//浏览按钮
	  		if(detailtype.equals("2")){
	  			if(hrmFieldBean.getIsFormField()){
		  			searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname);
	  			}else{
		  			searchConditionItem = conditionFactory.createCondition(ConditionType.DATE, fieldlabel, fieldname,detailtype);
		  			searchConditionItem.setDomkey(new String[]{fieldname + DATE_SELECT, fieldname + DATE_FROM, fieldname + DATE_TO});
		  			searchConditionItem.setOptions(ServiceUtil.getDateSelectFromTo(user.getLanguage()));
	  			}
	  		}else if(detailtype.equals("19")){
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.TIMEPICKER, fieldlabel, fieldname,detailtype);
	  		}else if(detailtype.equals("402")) { // 年
				searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname,detailtype);
				if (!isMobile.equals("1")) searchConditionItem.setFormat("yyyy");
				searchConditionItem.setMode("year");
				searchConditionItem.setPlaceholder(SystemEnv.getHtmlLabelNames("526306", user.getLanguage()));
				searchConditionItem.setShowTime(false);
			}else if (detailtype.equals("403")){
				searchConditionItem = conditionFactory.createCondition(ConditionType.DATEPICKER, fieldlabel, fieldname,detailtype);
				if (!isMobile.equals("1")) searchConditionItem.setFormat("yyyy-MM");
				searchConditionItem.setMode("month");
				searchConditionItem.setPlaceholder(SystemEnv.getHtmlLabelNames("126137", user.getLanguage()));
				searchConditionItem.setShowTime(false);
			}else if(detailtype.equals("RANGEPICKER")){//日期区间
				String[]  domkey= new String[]{ DATE_FROM+fieldname,DATE_TO+fieldname};
				searchConditionItem = conditionFactory.createCondition(ConditionType.RANGEPICKER, fieldlabel,domkey); 
				searchConditionItem.setValue(fieldvalue);
		  	}else if(detailtype.equals("TIMERANGEPICKER")){//时间区间
          String[]  domkey= new String[]{fieldname+DATE_Time_FROM,fieldname+DATE_Time_TO};
          searchConditionItem = conditionFactory.createCondition(ConditionType.TIMERANGEPICKER, fieldlabel,domkey);
          searchConditionItem.setValue(fieldvalue);
        }else{
					if(detailtype.equals("161")||detailtype.equals("162")||detailtype.equals("256")||detailtype.equals("257")){
//						BrowserBean browserbean = new BrowserBean(detailtype+"");
//						browser = browserInitUtil.initCustomizeBrow(browserbean, fielddbtype, detailtype, user.getUID());
//
//						searchConditionItem = new SearchConditionItem(ConditionType.BROWSER, SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()),new String[]{fieldname},browserbean);
//						if (detailtype.equals("256")||detailtype.equals("257")){
//							if(dmlurl.length()==0) {
//								RecordSet recordSet = new RecordSet();
//								recordSet.executeSql("select * from cus_formfield where fieldid = " + fieldid);
//								if (recordSet.next()) {
//									dmlurl = Util.null2String(recordSet.getString("dmlurl"));
//								}
//							}
//							searchConditionItem.getBrowserConditionParam().getConditionDataParams().put("cube_treeid", dmlurl);
//							searchConditionItem.getBrowserConditionParam().getDataParams().put("cube_treeid", dmlurl);
//							searchConditionItem.getBrowserConditionParam().getDestDataParams().put("cube_treeid", dmlurl);
//							searchConditionItem.getBrowserConditionParam().getCompleteParams().put("isshowall","1");
//							searchConditionItem.getBrowserConditionParam().getCompleteParams().put("cube_treeid", dmlurl);
//              searchConditionItem.getBrowserConditionParam().setHasAdvanceSerach(false);
//						}else{
//							Map<String,Object> otherParamsMap = new HashMap<>();
//							otherParamsMap.put("isMultCheckbox", true);
//							searchConditionItem.setOtherParams(otherParamsMap);
//						}
//						searchConditionItem.getBrowserConditionParam().getConditionDataParams().put("type", dmlurl);
//						searchConditionItem.getBrowserConditionParam().getDataParams().put("type", dmlurl);
//						searchConditionItem.getBrowserConditionParam().getCompleteParams().put("fielddbtype", dmlurl);
//						searchConditionItem.getBrowserConditionParam().getCompleteParams().put("type", dmlurl);
//						searchConditionItem.getBrowserConditionParam().getDestDataParams().put("type", dmlurl);
						BrowserBean browserbean = new BrowserBean(detailtype+"");
						BrowserInitUtil browserInitUtil = new BrowserInitUtil();
						String fielddbtype = dmlurl;
						if(!dmlurl.startsWith("browser.")){
							fielddbtype = "browser."+dmlurl;
						}
						if(detailtype.equals("161")||detailtype.equals("162")) {
							browserInitUtil.initCustomizeBrow(browserbean, fielddbtype, Util.getIntValue(detailtype), user.getUID());
						} else {
							browserbean.getDataParams().put("cube_treeid", dmlurl);
							browserbean.getDataParams().put("currenttime", System.currentTimeMillis());
							browserInitUtil.initBrowser(browserbean, user.getLanguage());
						}
						searchConditionItem = new SearchConditionItem(ConditionType.BROWSER, SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()),new String[]{fieldname},browserbean);
					}else{
						searchConditionItem = conditionFactory.createCondition(ConditionType.BROWSER, fieldlabel, fieldname,detailtype);
					}
					searchConditionItem.getBrowserConditionParam().setHideVirtualOrg(hrmFieldBean.getHideVirtualOrg());
					List<Map<String, Object>> replaceDatas = new ArrayList<Map<String, Object>>();
					String tmpFieldValue = Util.null2String(fieldvalue);
					if(detailtype.equals("mkqshift")){
						ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
						String[] fieldvalues = Util.splitString(tmpFieldValue, ",");
						for(int i=0;fieldvalues!=null&&i<fieldvalues.length;i++){
							String fieldshowname = Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(fieldvalues[i],user.getLanguage()));
							if(fieldshowname.length()==0)continue;
							Map<String, Object> replaceData = new HashMap<String, Object>();
							replaceData.put("id", fieldvalues[i]);
							replaceData.put("name", fieldshowname);
							replaceDatas.add(replaceData);
						}
					}else if(detailtype.equals("sensitivewordstype")){
						SensitiveWordTypeComInfo sensitiveWordTypeComInfo = new SensitiveWordTypeComInfo();
						String[] fieldvalues = Util.splitString(tmpFieldValue, ",");
						for(int i=0;fieldvalues!=null&&i<fieldvalues.length;i++){
							String fieldshowname = Util.null2String(sensitiveWordTypeComInfo.getName(fieldvalues[i]));
							if(fieldshowname.length()==0)continue;
							Map<String, Object> replaceData = new HashMap<String, Object>();
							replaceData.put("id", fieldvalues[i]);
							replaceData.put("name", fieldshowname);
							replaceDatas.add(replaceData);
						}
					}else if(detailtype.equals("doccategory")){
						List <BrowserValueInfo> fieldvalues = new BrowserValueInfoService().getBrowserValueInfo(detailtype,Util.null2String(fieldvalue));
						for(int i=0;fieldvalues!=null&&i<fieldvalues.size();i++){
							BrowserValueInfo valueInfo = fieldvalues.get(i);
							String fieldshowname = valueInfo.getName();
							if(fieldshowname.length()==0)continue;
							Map<String, Object> replaceData = new HashMap<String, Object>();
							replaceData.put("id", valueInfo.getId());
							replaceData.put("name", fieldshowname);
							replaceDatas.add(replaceData);
						}
					}else{
						if(tmpFieldValue.length()>0){
							String fieldshowname=hrmFieldManager.getFieldvalue(user, dmlurl, Util.getIntValue(fieldid), Util.getIntValue(fieldhtmltype), Util.getIntValue(detailtype), tmpFieldValue, 0);
							String[] fieldvalues = Util.splitString(tmpFieldValue, ",");
							String[] fieldshownames = Util.splitString(fieldshowname, ",");
							if (detailtype.equals("257")){
								if(fieldshowname.endsWith("&nbsp")){
									fieldshowname=fieldshowname.substring(0,fieldshowname.length()-5);
								}
								fieldshownames = Util.splitString(fieldshowname, "&nbsp");
							}
							for(int i=0;fieldvalues!=null&&i<fieldvalues.length;i++){
							  if(fieldvalues.length != fieldshownames.length){
							    break;
                }
								if(Util.null2String(fieldshownames[i]).length()==0)continue;
								Map<String, Object> replaceData = new HashMap<String, Object>();
								replaceData.put("id", fieldvalues[i]);
								replaceData.put("name", fieldshownames[i]);
								replaceDatas.add(replaceData);
							}
						}
					}
					fieldvalue = replaceDatas;
				}
	  	}else	if(fieldhtmltype.equals("4")){//Check框
	  		searchConditionItem = conditionFactory.createCondition(ConditionType.CHECKBOX, fieldlabel, fieldname);
	  		if(detailtype.equals("2")){
	  			searchConditionItem.setConditionType(ConditionType.SWITCH);
	  		}
//	  		else{
//	  			if(fieldvalue.equals("1")){
//	  				fieldvalue = true;
//		  		}else{
//		  			fieldvalue = false;
//		  		}
//	  		}
	  	}else if(fieldhtmltype.equals("5")){	//选择框
	  		List<SearchConditionOption> statusOptions = hrmFieldBean.getSelectOption();
				if(statusOptions==null)statusOptions = new ArrayList<SearchConditionOption>();
	  		try{
	  			if(fieldid.length()>0){
	  				rs = new RecordSet();
	  				char flag = Util.getSeparator();
	  				if(hrmFieldBean.getIsFormField()){
	  					if(Util.null2String(hrmFieldBean.getIssystem()).equals("1")){
	  						rs.executeProc("hrm_selectitembyid_new",""+fieldid+flag+1);
	  					}else{
	  						rs.executeProc("cus_selectitembyid_new",""+fieldid+flag+1);
	  					}
	  				}else{
	  					if(fieldname.startsWith("column_")){
	  						rs.executeProc("cus_selectitembyid_new",""+fieldid+flag+1);
	  					}else{
	  						rs.executeProc("hrm_searchselectitembyid",fieldid);
	  					}
	  				}
	  				while(rs.next()){
	  					String tmpselectvalue = Util.null2String(rs.getString("selectvalue"));
	  					String tmpselectname = Util.toScreen(rs.getString("selectname"),user.getLanguage());
	  					if(Util.null2String(rs.getString("cancel")).equals("1"))continue;
	  					boolean isDefault = Util.null2String(rs.getString("isdefault")).equals("y");
							if(!isDefault){
								isDefault = Util.null2String(rs.getString("hrm_isdefault")).equals("1");
							}
							SearchConditionOption searchConditionOption = new SearchConditionOption(tmpselectvalue,tmpselectname,isDefault);
							if(!statusOptions.contains(searchConditionOption)) {
								statusOptions.add(searchConditionOption);
							}
	  				}
	  			}
	  		}catch (Exception e) {
					writeLog(e);
				}
				searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, fieldlabel, fieldname, statusOptions);
				if(detailtype.equals("")||detailtype.equals("0")){
					detailtype="1";
				}
				searchConditionItem.setKey(Util.null2String(fieldvalue));
				searchConditionItem.setValue(fieldvalue);
				searchConditionItem.setDetailtype(Util.getIntValue(detailtype,3));
	  	}else if(fieldhtmltype.equals("6")){//附件
	  		if(fieldname.equals("resourceimageid")){
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, fieldlabel, fieldname,isQuickSearch);
	  		}else{
	  			searchConditionItem = conditionFactory.createCondition(ConditionType.UPLOAD, fieldlabel, fieldname,isQuickSearch);
	  			searchConditionItem.setUploadUrl("/api/doc/upload/uploadFile");
	  			searchConditionItem.setCategory("category");
					searchConditionItem.setMaxFilesNumber(10);
					searchConditionItem.setMultiSelection(true);
					Map<String,Object> otherParamsMap = new HashMap<>();
					otherParamsMap.put("showClearAll", false);
					otherParamsMap.put("showOrder", true);
					searchConditionItem.setOtherParams(otherParamsMap);
	  			if(Util.null2String(fieldvalue).length()>0){
	  				List<Object> datas = new ArrayList<Object>();
		  			Map<String, Object> data = null;
		  			String[] tmpIds = Util.splitString(Util.null2String(fieldvalue), ",");
		  			for(int i=0;i<tmpIds.length;i++){
		  				String fileid = tmpIds[i];
		  				ImageFileManager manager = new ImageFileManager();
		  				manager.getImageFileInfoById(Util.getIntValue(fileid));
		  				String filename = manager.getImageFileName();
		  				String extname = filename.contains(".") ? filename.substring(filename.lastIndexOf(".") + 1) : "";
		  				data = new HashMap<String, Object>();
		  				data.put("acclink", "/weaver/weaver.file.FileDownload?fileid="+fileid);
		  				data.put("fileExtendName", extname);
		  				data.put("fileid", fileid);
		  				if(Util.null2String(this.isMobile).equals("1")) {
								data.put("filelink", "/spa/document/static4mobile/index.html#/attach/" + fileid);
							}else{
								data.put("filelink", "/spa/document/index2file.jsp?imagefileId=" + fileid + "#/main/document/fileView");
							}
		  				data.put("filename", filename);
		  				data.put("filesize", manager.getImgsize());
		  				data.put("imgSrc", "");
		  				data.put("isImg", "");
		  				data.put("loadlink", "/weaver/weaver.file.FileDownload?fileid="+fileid+"&download=1");
		  				data.put("showDelete", "true");
		  				data.put("showLoad", "true");
		  				datas.add(data);
		  			}
		  			searchConditionItem.setDatas(datas);
	  			}
	  		}
	  	}else if(fieldhtmltype.equals("7")){//颜色选择
				searchConditionItem = conditionFactory.createCondition(ConditionType.COLORPICKER, fieldlabel,fieldname,true); 
				searchConditionItem.setValue(fieldvalue);
	  	}else if(fieldhtmltype.equals("8")){//DESCRIPTION
			searchConditionItem = conditionFactory.createCondition(ConditionType.DESCRIPTION, fieldlabel,fieldname);
			searchConditionItem.setValue(fieldvalue);
		}
	  	if(searchConditionItem!=null){
	  		BrowserInitUtil.setConditionItemDefaultValue(searchConditionItem, fieldvalue,2);
		  	searchConditionItem.setLabelcol(6);
		  	searchConditionItem.setFieldcol(12);
		  	searchConditionItem.setViewAttr(viewAttr);
		  	if (searchConditionItem.getBrowserConditionParam() != null) {
					searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr);
				}
		  	if(searchConditionItem.getConditionType().equals(ConditionType.DATE)){
		  		searchConditionItem.setFieldcol(18);
		  	}
		  	if(Util.null2String(hrmFieldBean.getRules()).length()>0){
		  		searchConditionItem.setRules(hrmFieldBean.getRules());
		  	}
		   	if(Util.null2String(hrmFieldBean.getTip()).length()>0){
		   		searchConditionItem.setHelpfulTip(hrmFieldBean.getTip());
		  	}
		  	if(Util.null2String(hrmFieldBean.getFieldlabelname()).length()>0){
					searchConditionItem.setLabel(hrmFieldBean.getFieldlabelname());
				}
        if (hrmFieldBean.getOtherparam() != null) {
          searchConditionItem.setOtherParams(hrmFieldBean.getOtherparam());
        }

				if(fieldhtmltype.equals("1") && detailtype.equals("1")){
					if(multilang && hrmFieldBean.getIsFormField()){
						ServiceUtil.addMultiLanguageProperty(searchConditionItem);
					}
				}
	  	}
		}catch (Exception e) {
			writeLog(e);
		}
		
		return searchConditionItem;
	}

	public void setIsMobile(String isMobile){
		this.isMobile = isMobile;
	}
}